﻿using System;
using System.Collections.Generic;
using AutoResumeSend.DAC;
using AutoResumeSend.Entity;
namespace AutoResumeSend.Componments
{
    public class SqlManager
    {
           /// <summary>
       /// 添加发送简历邮件条目
       /// </summary>
       /// <param name="occurInfo"></param>
       /// <returns></returns>
        public int AddResumeSendInfo(WebSiteInfo occurInfo)
        {
            SqlDao dao = new SqlDao();
            try
            {
               int ret=  dao.AddResumeSendInfo(occurInfo);
               return ret;
            }
            catch (Exception ex)
            {
                LogHelper.LogError("添加发送简历的职位条目失败" + ex.ToString());
                ex = null;
            }
            return -1;
        }

        /// <summary>
        /// 获取最近抓取的时间
        /// </summary>
        /// <param name="webId"></param>
        /// <returns></returns>
        public DateTime GetLastTime(int webId)
        {
              SqlDao dao = new SqlDao();
            DateTime dt = DateTime.MinValue;
            try
            {
                dt = dao.GetLastSendTime(webId);
            }
            catch (Exception ex)
            {
                LogHelper.LogError("获取最近抓取的时间失败" + ex.ToString());
                ex = null;
            }
            return dt;
        }

        /// <summary>
        /// 检查是否是已经存在的邮件
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool isExistEmail(string email)
        {
            try
            {
                SqlDao dao = new SqlDao();
                return dao.isExistEmail(email);
            }
            catch (Exception ex)
            {
                LogHelper.LogError("检查邮件是否存在失败" + ex.ToString());
                ex = null;
                return false;
            }
        }

    }
}
